package cn.com.jonpad.cfgbeans;

import cn.com.ribbon.CustomRuleConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 *
 * RibbonClient(name = "唯一标识一组客户端资源既要调用的微服务名称",configuration = 自定义规则.class)
 * 注意！它不在主应用程序上下文的@ComponentScan中，否则它将由所有@RibbonClients共享。
 * <link>http://cloud.spring.io/spring-cloud-static/Edgware.SR4/single/spring-cloud.html#_customizing_the_ribbon_client</link>
 * @author user
 */
@Configuration
@RibbonClient(name = "MICROSERVICECLOUD-DEPT",configuration = CustomRuleConfiguration.class)
public class ConfigBean {
	/**
	 * 获得Rest时加入Ribbon的配置
	 * @return
	 */
	@Bean
	@LoadBalanced
	public RestTemplate getRestTemplate()
	{
		return new RestTemplate();
	}

}
